package com.rg1906.dao.Impl;

import java.sql.SQLException;

import javax.sql.DataSource;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import com.rg1906.dao.LoginDao;
import com.rg1906.entity.LoginUser;
import com.rg1906.utils.DataSourceC3P0ThreadLocal;

public class LoginDaoImpl implements LoginDao{
	DataSource dataSource = DataSourceC3P0ThreadLocal.getDataSource();
	QueryRunner qr = new QueryRunner(dataSource);
	public LoginUser Login(String loginName, String loginPassword) throws SQLException {
		String sql="select id,loginName,loginPassword,rid,img from t_user where loginName=? and loginPassword=?";
		Object[] par= {loginName,loginPassword};
		return qr.query(sql, new BeanHandler<>(LoginUser.class),par);
	}

}
